-- wear_gem
-- create by zhuangsl
-- 首次穿戴奖励钻石

return {
    apply = function(prop, baseValue)
        -- 数量
        return prop[3];
    end,

    -- 穿戴装备触发
    trigger = function(who, prop, classId)
        if who.type ~= OBJECT_TYPE_USER then
            return;
        end

        local propId = tonumber(prop[1]);
        local buffDataId = tonumber(prop[2]);
        local v = prop[3];
        local limitTimes = prop[4];

        -- 预先处理一下
        if not EquipM.doWearTrigger(who, classId, propId, attrib) then
            return 0;
        end

        -- 次数限制（永久起效）
        local times = BuffDataM.query("limited_gem", buffDataId);
        if limitTimes > 0 and times >= limitTimes then
            return;
        end
        BuffDataM.set("limited_gem", buffDataId, times + 1);

        local bonus = {2, "gem", v, };
        BonusM.doBonus(bonus, "wear_bonus");

        -- 奖励事件
        EventMgr.fire(event.SKILL_BONUS, { ["bonus"] = bonus});
    end,

    record = function(target, prop, path)
        return false;
    end,
};
